package com.jlpay.openapi.demo.trans.mini.alipay;

import com.jlpay.open.jlpay.sdk.java.model.trans.mini.alipay.request.WapPayRequest;
import com.jlpay.open.jlpay.sdk.java.model.trans.mini.alipay.response.WapPayResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author dengwenning
 * @since 2024/9/23
 **/
public class WapPayService {
    private static final Logger LOGGER = LoggerFactory.getLogger(WapPayService.class);

    public static void main(String[] args) {
        WapPayRequest wapPayRequest = buildWapPayRequest();
        WapPayResponse wapPayResponse = JlpayOpenApiService.openMerchService()
                .post(wapPayRequest, WapPayResponse.class);
        LOGGER.info("支付宝服务窗下单响应:{}", JsonUtils.toString(wapPayResponse));
    }

    private static WapPayRequest buildWapPayRequest() {
        WapPayRequest wapPayRequest = new WapPayRequest();

        wapPayRequest.setMchId("849584358120018");
        wapPayRequest.setTermNo("60131234");
        wapPayRequest.setPayType("alipay");
        wapPayRequest.setBuyerLogonId("251345262@qq.com");
        wapPayRequest.setBuyerId("2088124533344");
        wapPayRequest.setLimitPay("no_credit");
        wapPayRequest.setOutTradeNo("ld201911023465529");
        wapPayRequest.setPaymentValidTime("10");
        wapPayRequest.setBody("充值中心-会员充值");
        wapPayRequest.setAttach("商城—-易拉宝10个打印纸20箱");
        wapPayRequest.setTotalFee("1");
        wapPayRequest.setIsHirePurchase("1");
        wapPayRequest.setHirePurchaseNum("3");
        wapPayRequest.setHirePurchaseSellerPercent("0");
        wapPayRequest.setRemark("该订单物流请走顺丰快递");
        wapPayRequest.setNotifyUrl("https://help.jlpay.com/api/docs/home");
        wapPayRequest.setOpUserId("001");
        wapPayRequest.setOpShopId("GD_SZ_001");
        wapPayRequest.setDeviceInfo("N50007A8890");
        wapPayRequest.setMchCreateIp("123.12.12.123");
        wapPayRequest.setLongitude("116.078631");
        wapPayRequest.setLatitude("39.71274");

        return wapPayRequest;
    }
}
